﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RutTrichThongTin.Models;

namespace RutTrichThongTin.Controllers
{
    public class FeederController : Controller
    {
        public ActionResult VeMayBay()
        {
            var SanBay = new Dictionary<string, string>();
            SanBay.Add("Chọn địa điểm", "0");
            SanBay.Add("Buôn Mê Thuột","BMV");
            SanBay.Add("Cà Mau", "CAH");
            SanBay.Add("Côn Đảo", "VCS");
            SanBay.Add("Cần Thơ", "VCA");
            SanBay.Add("Hà Nội", "HAN");
            SanBay.Add("Hải Phòng", "HPH");
            SanBay.Add("Nha Trang", "NHA");
            SanBay.Add("Phú Quốc", "PQC");
            SanBay.Add("Quy Nhơn", "UIH");
            SanBay.Add("Rạch Giá", "VKG");
            SanBay.Add("TP.Hồ Chí Minh", "SGN");
            SanBay.Add("Tuy Hòa", "TBB");
            SanBay.Add("Điện Biên", "DIN");
            SanBay.Add("Đà Lạt", "DAD");
            SanBay.Add("Sydney", "SYD");
            ViewBag.SanBay = SanBay;

            AirPlaneTicketFeederManager airPlaneManager = new AirPlaneTicketFeederManager();
            string path = Server.MapPath("~/App_Data");
            airPlaneManager.LoadFeederLibrary(path);
            Dictionary<string,int> CuaHang = airPlaneManager.CuaHang;
            ViewBag.CuaHang = CuaHang;
            return View();
        }

        [HttpPost]
        public ActionResult VeMayBay(VeMayBayModel model)
        {
            

            ViewBag.ThongTimTimKiem = model;            
            AirPlaneTicketFeederManager airPlaneManager = new AirPlaneTicketFeederManager();
            string path = Server.MapPath("~/App_Data");
            airPlaneManager.LoadFeederLibrary(path);

            int idCuaHang = Convert.ToInt32(model.TenCuaHang);
            List<string> listCol = airPlaneManager.getListColumn(idCuaHang);
            List<IAirPlanePlugin.AirPlaneTicketInfo> list   = airPlaneManager.getTicket(model.NoiDi,model.NoiDen,model.NgayDi,model.ThangDi,idCuaHang);

            ViewBag.KetQuaTimKiem = list;
            ViewBag.ListColumn = listCol;
            ViewBag.IdCuaHang = idCuaHang;

            return View("KetQuaTimVeMayBay");
        }


        public ActionResult DienThoai()
        {
            return View();
        }


        [HttpPost]
        public ActionResult DienThoai(DienThoaiModel model)
        {
            PhoneFeederManager PhoneFeederManager = new PhoneFeederManager();
            string path = Server.MapPath("~/App_Data");
            PhoneFeederManager.LoadFeederLibrary(path);
            List<IPhonePlugin.PhoneInfo> listPhone = PhoneFeederManager.GetSearchResult(model.TenDienThoai);
            ViewBag.DanhSachDienThoai = listPhone;
            return View("KetQuaTimDienThoai");
        }
    }
}
